package com.zhijian.medical.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author HCG
 * @version 1.0
 * @date 2023-09-26
 */
@AllArgsConstructor
@Getter
public enum MeetingRoomHourEnum {

    T0(0, "00:00-00:30"),
    T1(1, "00:30-01:00"),
    T2(2, "01:00-01:30"),
    T3(3, "01:30-02:00"),
    T4(4, "02:00-02:30"),
    T5(5, "02:30-03:00"),
    T6(6, "03:00-03:30"),
    T7(7, "03:30-04:00"),
    T8(8, "04:00-04:30"),
    T9(9, "04:30-05:00"),
    T10(10, "05:00-05:30"),
    T11(11, "05:30-06:00"),
    T12(12, "06:00-06:30"),
    T13(13, "06:30-07:00"),
    T14(14, "07:00-07:30"),
    T15(15, "07:30-08:00"),
    T16(16, "08:00-08:30"),
    T17(17, "08:30-09:00"),
    T18(18, "09:00-09:30"),
    T19(19, "09:30-10:00"),
    T20(20, "10:00-10:30"),
    T21(21, "10:30-11:00"),
    T22(22, "11:00-11:30"),
    T23(23, "11:30-12:00"),
    T24(24, "12:00-12:30"),
    T25(25, "12:30-13:00"),
    T26(26, "13:00-13:30"),
    T27(27, "13:30-14:00"),
    T28(28, "14:00-14:30"),
    T29(29, "14:30-15:00"),
    T30(30, "15:00-15:30"),
    T31(31, "15:30-16:00"),
    T32(32, "16:00-16:30"),
    T33(33, "16:30-17:00"),
    T34(34, "17:00-17:30"),
    T35(35, "17:30-18:00"),
    T36(36, "18:00-18:30"),
    T37(37, "18:30-19:00"),
    T38(38, "19:00-19:30"),
    T39(39, "19:30-20:00"),
    T40(40, "20:00-20:30"),
    T41(41, "20:30-21:00"),
    T42(42, "21:00-21:30"),
    T43(43, "21:30-22:00"),
    T44(44, "22:00-22:30"),
    T45(45, "22:30-23:00"),
    T46(46, "23:00-23:30"),
    T47(47, "23:30-24:00");

    private Integer code;
    private String desc;

    public static MeetingRoomHourEnum getByCode(Integer code) {
        MeetingRoomHourEnum[] values = MeetingRoomHourEnum.values();
        for (MeetingRoomHourEnum anEnum : values) {
            if (anEnum.getCode().equals(code)) {
                return anEnum;
            }
        }
        return null;
    }

    public static MeetingRoomHourEnum getByBeginTime(String beginTime) {
        MeetingRoomHourEnum[] values = MeetingRoomHourEnum.values();
        for (MeetingRoomHourEnum anEnum : values) {
            if (anEnum.getDesc().split("-")[0].equals(beginTime)) {
                return anEnum;
            }
        }
        return null;
    }
}
